<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"--%>
<%--"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">--%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>宿舍信息检索</title>
    <link href="/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css">
    <link href="/layui/css/layui.css" rel="stylesheet" type="text/css">
    <link href="/css/style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script src="/bootstrap/js/bootstrap.js" type="text/javascript"></script>
    <script src="/layui/layui.js" type="text/javascript"></script>
    <%--    <script src="/js/custom/viewTempRecordInfo.js"></script>--%>
    <link id="layuicss-layer" rel="stylesheet"
          href="http://localhost:8080/layui/css/modules/layer/default/layer.css?v=3.1.1" media="all">
    <link id="layuicss-laydate" rel="stylesheet"
          href="http://localhost:8080/layui/css/modules/laydate/default/laydate.css?v=5.0.9" media="all">
</head>

<body style="">
<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="#">首页</a></li>
        <li><a href="#">信息检索</a></li>
        <li><a href="#">宿舍信息检索</a></li>
    </ul>
</div>

<div class="rightinfo">
    <div class="tools">
        <form class="form-inline" action="/DormitoryController.do?action=listpage&pageIndex=1&pageSize=${pageUtil.pageSize}" method="post" id="queryForm">
            <div class="form-group">
                <label >院系标题</label>
                <input type="text" class="form-control stuSearch" value="${dormitoryName}"  name="dormitoryName" placeholder="请输入宿舍名称">
            </div>
            <div class="form-group text-right">
                <button type="submit" class="btn btn-primary" >查询</button>
            </div>
        </form>
    </div>

    <!--表格头部-->
    <script type="text/html" id="tablebar"></script>
    <!--layui数据表格-->
    <table id="tempRecordTableId" lay-filter="tempRecordTableFilter"></table>
    <div class="layui-form layui-border-box layui-table-view" lay-filter="LAY-table-1" lay-id="tempRecordTable"
         style=" ">
        <div class="layui-table-tool">
            <div class="layui-table-tool-temp"> <div class="layui-btn-container">
                <button class="layui-btn layui-btn-sm" onclick="location.href='/addDormitory.jsp';" lay-event="add" data-method="addStuInfo">添加</button> </div> </div>
            <div class="layui-table-tool-self">
                <div class="layui-inline" title="筛选列" lay-event="LAYTABLE_COLS"><i
                        class="layui-icon layui-icon-cols"></i></div>
                <div class="layui-inline" title="导出" lay-event="LAYTABLE_EXPORT"><i
                        class="layui-icon layui-icon-export"></i></div>
                <div class="layui-inline" title="打印" lay-event="LAYTABLE_PRINT"><i
                        class="layui-icon layui-icon-print"></i></div>
            </div>
        </div>

        <div class="layui-table-box">
            <div class="layui-table-header">
                <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                    <thead>
                    <tr>
                        <th data-field="0" data-key="1-0-0" data-unresize="true" class=" layui-table-col-special">
                            <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers"><span>序号</span>
                            </div>
                        </th>
                        <th data-field="stuId" data-key="1-0-1" data-minwidth="100" class="">
                            <div class="layui-table-cell laytable-cell-1-0-1" align="center"><span>宿舍编号</span></div>
                        </th>
                        <th data-field="stuId" data-key="1-0-1" data-minwidth="100" class="">
                            <div class="layui-table-cell laytable-cell-1-0-1" align="center"><span>宿舍标题</span></div>
                        </th>
                        <th data-field="stuName" data-key="1-0-2" data-minwidth="100" class="">
                            <div class="layui-table-cell laytable-cell-1-0-2" align="center"><span>宿舍描述</span></div>
                        </th>
                        <th data-field="stuTemp" data-key="1-0-7" data-minwidth="80" class="">
                            <div class="layui-table-cell laytable-cell-1-0-7" align="center"><span>操作</span></div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
            <div class="layui-table-body layui-table-main">
                <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                    <tbody>
                    <c:forEach items="${pageUtil.datas}" var="dormitory" varStatus="sta">
                        <tr data-index="0" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">${sta.index+1}</div>
                            </td>
                            <td data-field="stuId" data-key="1-0-1" align="center" data-minwidth="100" class="">
                                <div class="layui-table-cell laytable-cell-1-0-1">${dormitory.dormitoryId}</div>
                            </td>
                            <td data-field="stuId" data-key="1-0-1" align="center" data-minwidth="100" class="">
                                <div class="layui-table-cell laytable-cell-1-0-1">${dormitory.dormitoryName}</div>
                            </td>
                            <td data-field="stuName" data-key="1-0-2" align="center" data-minwidth="100" class="">
                                <div class="layui-table-cell laytable-cell-1-0-2">${dormitory.remark}</div>
                            </td>
                            <td data-field="stuTemp" data-key="1-0-7" align="center" data-minwidth="80" class="">
                                <div class="layui-table-cell laytable-cell-1-0-7">
                                    <button class="layui-btn layui-btn-xs data-count-edit" data-method="modifyStuInfo" lay-event="modify" onclick="goupdate(${dormitory.dormitoryId});">
                                        <i class="layui-icon layui-icon-edit" ></i>修改 </button>

                                    <button class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete" onclick="deleteDormitory(${dormitory.dormitoryId});">
                                        <i class="layui-icon layui-icon-delete"></i>删除</button>
                                </div>
                            </td>
                        </tr>
                    </c:forEach>
                    </tbody>
                </table>
            </div>
            <div class="layui-table-fixed layui-table-fixed-l">
                <div class="layui-table-header">
                    <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                        <thead>
                        <tr>
                            <th data-field="0" data-key="1-0-0" data-unresize="true" class=" layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers"><span>序号</span>
                                </div>
                            </th>
                        </tr>
                        </thead>
                    </table>
                </div>
                <div class="layui-table-body" style="height: 307px;">
                    <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                        <tbody>
                        <tr data-index="0" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">1</div>
                            </td>
                        </tr>
                        <tr data-index="1" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">2</div>
                            </td>
                        </tr>
                        <tr data-index="2" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">3</div>
                            </td>
                        </tr>
                        <tr data-index="3" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">4</div>
                            </td>
                        </tr>
                        <tr data-index="4" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">5</div>
                            </td>
                        </tr>
                        <tr data-index="5" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">6</div>
                            </td>
                        </tr>
                        <tr data-index="6" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">7</div>
                            </td>
                        </tr>
                        <tr data-index="7" class="">
                            <td data-field="0" data-key="1-0-0" class="layui-table-col-special">
                                <div class="layui-table-cell laytable-cell-1-0-0 laytable-cell-numbers">8</div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="layui-table-page">
            <div id="layui-table-page1">
                <div class="layui-box layui-laypage layui-laypage-default" id="layui-laypage-1">
                    <!--上一页按钮-->
                    <a href="javascript:gopage(${pageUtil.pageIndex-1},${pageUtil.pageCount},${pageUtil.pageSize});" class="layui-laypage-prev" data-page="0"><i
                            class="layui-icon"></i></a>
                    <c:forEach begin="${pageUtil.startNum}" end="${pageUtil.endNum}" var="num">
                        <c:if test="${pageUtil.pageIndex==num}">
                            <span class="layui-laypage-curr"><em class="layui-laypage-em"></em><em>${num}</em></span>
                        </c:if>
                        <c:if test="${pageUtil.pageIndex!=num}">
                            <a href="javascript:gopage(${num},${pageUtil.pageCount},${pageUtil.pageSize});"><span class="layui-laypage-count"><em class="layui-laypage-em"></em><em>${num}</em></span></a>
                        </c:if>
                    </c:forEach>

                    <!--下一页按钮-->
                    <a href="javascript:gopage(${pageUtil.pageIndex+1},${pageUtil.pageCount},${pageUtil.pageSize});" class="layui-laypage-next"
                       data-page="2"><i class="layui-icon"></i></a>

                    <span class="layui-laypage-skip">到第

                        <input type="text" min="1" value="${pageUtil.pageIndex}" id="numpage" class="layui-input">页<button
                                type="button" onclick="jumpPage(${pageUtil.pageCount},${pageUtil.pageSize});" class="layui-laypage-btn">确定</button></span>

                    <span class="layui-laypage-count">共 ${pageUtil.totalCount} 条</span>
                    <span class="layui-laypage-count">共 ${pageUtil.pageIndex}/${pageUtil.pageCount} 页</span>
                    <span class="layui-laypage-limits">
                    <select lay-ignore="" onchange="changePage(${pageUtil.pageCount});" id="selectPage">
                        <option value="5" ${pageUtil.pageSize==5?'selected':''} >5 条/页</option>
                        <option value="10" ${pageUtil.pageSize==10?'selected':''}>10 条/页</option>
                        <option value="15" ${pageUtil.pageSize==15?'selected':''}>15 条/页</option>
                        <option value="20" ${pageUtil.pageSize==20?'selected':''}>20 条/页</option>
                    </select>
                    </span>
                </div>
            </div>
        </div>
        <style>
            .laytable-cell-1-0-0 {
                width: 290px;
            }

            .laytable-cell-1-0-1 {
                width: 290px;
            }

            .laytable-cell-1-0-2 {
                width: 290px;
            }

        </style>
    </div>
</div>

<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');


    function gopage(pageIndex,pageCount,pageSize) {
        if(pageIndex<=0){
            alert("已经是第一页啦！");
            return;
        }
        if(pageIndex>pageCount){
            alert("已经是最后一页！");
            return;
        }
        //修改action属性
        $("#queryForm").prop("action", "/DormitoryController.do?action=listpage&pageIndex=" + pageIndex+"&pageSize="+pageSize);
        //表单提交 搜素参数也会提交
        $("#queryForm").submit();
    }

    function jumpPage(pageCount,pageSize) {
        var pageIndex= $("#numpage").val();
        if(pageIndex>=1&&pageIndex<=pageCount){
            gopage(pageIndex,pageCount,pageSize);
        }else{
            alert("页码不合法");
        }
    }

    function changePage(pageCount) {
        var pageSize=$("#selectPage").val();
        gopage(1,pageCount,pageSize);
    }

    /**
     * 删除
     * @param dormitoryId
     */
    function deleteDormitory(dormitoryId) {
        if(confirm("确定是否删除?")){
            location.href="/DormitoryController.do?action=delete&dormitoryId="+dormitoryId;
        }
    }

    //跳转更新页面
    function goupdate(dormitoryId) {
        location.href="/DormitoryController.do?action=goupdate&dormitoryId="+dormitoryId;
    }

</script>


</body>
</html>


